<!-- A beautiful app starts with a beautiful code :) -->

<!-- /userSpan/monitoringUserSpan -->

<!-- Header -->
<div class="main-window-segment header-segment bottom-padded">
    <div class="container-fluid">
        <div class="row">

            <div class="col-lg-10 col-md-6 col-sm-12">
                <h2>Daftar User OMSPAN</h2>
            </div>
			<div class="col-lg-1 col-md-3 col-sm-12" style="padding-top: 20px;">
                <button type="button" class="btn btn-default fullwidth" data-toggle="modal" data-target="#modal-app-tambah"><span class="glyphicon glyphicon-headphones"></span> Tambah</button>

            </div>
            <div class="col-lg-1 col-md-3 col-sm-12" style="padding-top: 20px;">

                <button type="button" class="btn btn-default fullwidth" data-toggle="modal" data-target="#modal-app-filter"><span class="glyphicon glyphicon-filter"></span> Filter</button>

            </div>
        </div>

        <div class="row">

            <div class="col-md-6 col-sm-12">
<?php
if (isset($this->d_nama_kppn)) {
    foreach ($this->d_nama_kppn as $kppn) {
        echo $kppn->get_nama_user() . " (" . $kppn->get_kd_satker() . ")";
        $kode_kppn = $kppn->get_kd_satker();
    }
}

if (isset($this->d_nip1)) {
    echo "<br>NIP Semula : ".$this->d_nip1;
}

if (isset($this->d_nip2)) {
    echo "<br>NIP Menjadi : ".$this->d_nip2;
}
?>
            </div>

            <div class="col-md-6 col-sm-12 align-right">
                <?php
                // untuk menampilkan last_update
                if (isset($this->last_update)) {
                    foreach ($this->last_update as $last_update) {
                        echo "Update Data Terakhir (Waktu Server)<br/>" . $last_update->get_last_update() . " WIB";
                    }
                }
                ?>
            </div>

        </div>

    </div>
</div>

<div id="table-container" class="wrapper">
    <table class="footable align-center">

        <thead>
            <tr>
                <th>No.</th>
                <th>Nama </th>
                <th>Username</th>
                <th>Password</th>
                <th>Kewenangan</th>
                <th>Kode Dept<br>Kode Unit</th>
                <th>KPPNnya<br>Kanwilnya</th>
                <th>Tanggal Daftar</th>
                <th >Ubah</th>
            </tr>
        </thead>

        <tbody>

<?php $no = 1; ?>

<?php if (isset($this->data)) { ?>

    <?php if (empty($this->data)) { ?>

            <tr><td colspan=10 class="align-center">Tidak ada data.</td></tr>

                <?php } else { ?>

                    <?php foreach ($this->data as $value) { ?>
                    <tr>
                        <td><?php echo $no++; ?></td>
                        <td align='left'><?php echo $value->get_nama_user(); ?> </td>
                        <td><?php echo $value->get_kd_satker(); ?> </td>
                        <td><?php echo $value->get_pass_user(); ?> </td>
                        <td><?php echo Wewenang::status_int_string($value->get_kd_r_jenis());?></td>
                        <td><?php echo $value->get_kd_dept()."<br>".$value->get_kd_unit();?> </td>
                        <td><?php echo $value->get_kd_d_kppn()."<br>".$value->get_kd_kanwil();?> </td>
                        <td><?php echo $value->get_tgl_daftar(); ?> </td>
                        <td ><a class="btn btn-default" data-toggle="modal" data-target="#modal-app-update<?php echo $value->get_kd_d_user();?>" name="upd_d_user"><span class="glyphicon glyphicon-pencil"></span></a></span></a>
                        </td>
                    </tr>

<!--Update Data-->
<div class="modal fade" id="modal-app-update<?php echo $value->get_kd_d_user();?>" tabindex="-1" role="dialog" aria-labelledby="app-filter-label" aria-hidden="true">

    <div class="modal-dialog">

        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">   <span aria-hidden="true">&times;</span><span class="sr-only">Tutup</span></button>
                <h4 class="modal-title" id="app-filter-label"><span class="glyphicon glyphicon-headphones"></span> Update Data</h4>

            </div>
            
            <form id="filter-form" method="POST" action="pergantianUser" enctype="multipart/form-data">

                <div class="modal-body">
                    
                    <div id="wnama" class="alert alert-danger" style="display: none"></div>
                    <label class="isian">Nama : </label>
                    <input class='form-control' type="text" name="nama" id="nama" size="50" value="<?php echo $value->get_nama_user();?>">
                    <br/>
                    
                    <div id="wusername" class="alert alert-danger" style="display: none"></div>
                    <label class="isian"> Username: </label>
                    <input class='form-control' type="text" name="username" id="username" size="50" value="<?php echo $value->get_kd_satker();?>">
                    <br/>
                    
                    <div id="wpass" class="alert alert-danger" style="display: none"></div>
                    <label class="isian"> Password: </label>
                    <input class='form-control' type="text" name="pass" id="pass" size="50" value="<?php echo $value->get_pass_user();?>">
                    <br/>
                    
                    <div id="wkewenangan" class="alert alert-danger" style="display: none"></div>
                    <label class="isian"> Kewenangan: </label>
                    <select class="form-control" type="text" name="kewenangan" id="kewenangan">
                        <option value="">-</option>
                        <option value="1" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='Admin') echo "selected";?>>Admin</option>
                        <option value="2" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='Satker') echo "selected";?>>Satker</option>
                        <option value="3" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='KPPN') echo "selected";?>>KPPN</option>
                        <option value="4" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='PKN') echo "selected";?>>PKN</option>
                        <option value="5" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='Kanwil') echo "selected";?>>Kanwil</option>
                        <option value="6" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='DJA') echo "selected";?>>DJA</option>
                        <option value="7" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='BLU') echo "selected";?>>BLU</option>
                        <option value="8" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='Bank') echo "selected";?>>Bank</option>
                        <option value="11" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='KL') echo "selected";?>>K/L</option>
                        <option value="12" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='ES1') echo "selected";?>>Eselon 1</option>
                        <option value="13" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='UMADMIN') echo "selected";?>>UMADMIN</option>
                        <option value="14" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='Menkeu') echo "selected";?>>Menkeu</option>
                        <option value="15" <?php if (Wewenang::status_int_string($value->get_kd_r_jenis())=='SUPER') echo "selected";?>>SUPER</option>
                    </select>
                    <br/>
                    
                    <div id="wdept" class="alert alert-danger" style="display: none"></div>
                    <label class="isian"> Departemen: </label>
                    <input class='form-control' type="text" name="dept" id="dept" size="50" value="<?php echo $value->get_kd_dept();?>">
                    <br/>
                    
                    <div id="wunit" class="alert alert-danger" style="display: none"></div>
                    <label class="isian"> Unit Eselon1: </label>
                    <input class='form-control' type="text" name="unit" id="unit" size="50" value="<?php echo $value->get_kd_unit();?>">
                    <br/>
                    
                    <div id="wkdkppn" class="alert alert-danger" style="display:none;"></div>
                        <label class="isian">Kode KPPN: </label>

                        <select class="form-control" type="text" name="kdkppn" id="kdkppn">
                        <option value="SEMUAKPPN">-</option>
    <?php foreach ($this->kppn_list as $value1) { ?>

        <?php if ($value->get_kd_d_kppn() == $value1->get_kd_d_kppn()) { ?>

                                    <option value="<?php echo $value1->get_kd_d_kppn(); ?>" selected><?php echo $value1->get_kd_d_kppn(); ?> | <?php echo $value1->get_nama_user(); ?></option>

                                <?php } else { ?>

                                    <option value="<?php echo $value1->get_kd_d_kppn(); ?>"><?php echo $value1->get_kd_d_kppn(); ?> | <?php echo $value1->get_nama_user(); ?></option>

        <?php } ?>

                            <?php } ?>

                        </select>
                    <br/>
                    
                    <div id="wkanwil" class="alert alert-danger" style="display: none"></div>
                    <label class="isian"> Kanwil: </label>
                    <input class='form-control' type="text" name="kanwil" id="kanwil" size="50" value="<?php echo $value->get_kd_kanwil();?>">
                    <br/>
                </div>
                <div class="modal-footer">
                    <button type="submit" name="submit_file" class="btn btn-primary" style="width: 100%" onClick="">Kirim</button>
                </div>

            </form>
        </div>

    </div>

</div>
<!--End of Update Data-->
        <?php }  ?>

    <?php } ?>

<?php } else { ?>

            <td colspan=8 class="align-center" id="filter-first">Silahkan masukkan filter terlebih dahulu.</td>

        <?php } ?>

        </tbody>

    </table>
</div> <!--end table-->


<!-- Tambah Data -->
<!--end modal tambah-->

<!-- Filter -->

<div class="modal fade" id="modal-app-filter" tabindex="-1" role="dialog" aria-labelledby="app-filter-label" aria-hidden="true">

    <div class="modal-dialog">

        <div class="modal-content">

            <div class="modal-header">

                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Tutup</span></button>
                <h4 class="modal-title" id="app-filter-label"><span class="glyphicon glyphicon-filter"></span> Filter Data</h4>

            </div>

            <form id="filter-form" method="POST" action="getDataUser" enctype="multipart/form-data">

                <div class="modal-body">
                    
                    <div id="wf_username" class="alert alert-danger" style="display: none"></div>
                    <label class="isian"> Username: </label>
                    <input class='form-control' type="text" name="f_username" id="f_username" size="50" value="<?php if(isset($this->d_f_username)) echo $this->d_f_username;?>">
                    <br/>
                    
                    <div id="wf_kewenangan" class="alert alert-danger" style="display: none"></div>
                    <label class="isian"> Kewenangan: </label>
                    <select class="form-control" type="text" name="f_kewenangan" id="f_kewenangan">
                        <option value="">-</option>
                        <option value="1" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='Admin') echo "selected";?>>Admin</option>
                        <option value="2" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='Satker') echo "selected";?>>Satker</option>
                        <option value="3" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='KPPN') echo "selected";?>>KPPN</option>
                        <option value="4" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='PKN') echo "selected";?>>PKN</option>
                        <option value="5" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='Kanwil') echo "selected";?>>Kanwil</option>
                        <option value="6" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='DJA') echo "selected";?>>DJA</option>
                        <option value="7" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='BLU') echo "selected";?>>BLU</option>
                        <option value="8" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='Bank') echo "selected";?>>Bank</option>
                        <option value="11" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='KL') echo "selected";?>>K/L</option>
                        <option value="12" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='ES1') echo "selected";?>>Eselon 1</option>
                        <option value="13" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='UMADMIN') echo "selected";?>>UMADMIN</option>
                        <option value="14" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='Menkeu') echo "selected";?>>Menkeu</option>
                        <option value="15" <?php if (Wewenang::status_int_string($this->d_f_kewenangan)=='SUPER') echo "selected";?>>SUPER</option>
                    </select>
                    <br/>
                    
                    <div id="wf_dept" class="alert alert-danger" style="display: none"></div>
                    <label class="isian"> Departemen: </label>
                    <input class='form-control' type="text" name="f_dept" id="f_dept" size="50" value="<?php if(isset($this->d_f_dept))echo $this->d_f_dept;?>">
                    <br/>
                    
                    <div id="wf_unit" class="alert alert-danger" style="display: none"></div>
                    <label class="isian"> Unit Eselon1: </label>
                    <input class='form-control' type="text" name="f_unit" id="f_unit" size="50" value="<?php if(isset($this->d_f_unit))echo $this->d_f_unit;?>">
                    <br/>
                    
                    <div id="wf_kdkppn" class="alert alert-danger" style="display:none;"></div>
                        <label class="isian">Kode KPPN: </label>

                        <select class="form-control" type="text" name="f_kdkppn" id="f_kdkppn">
                        <option value="SEMUAKPPN">-</option>
    <?php foreach ($this->kppn_list as $value1) { ?>

        <?php if ($this->d_f_kdkppn == $value1->get_kd_d_kppn()) { ?>

                                    <option value="<?php echo $value1->get_kd_d_kppn(); ?>" selected><?php echo $value1->get_kd_d_kppn(); ?> | <?php echo $value1->get_nama_user(); ?></option>

                                <?php } else { ?>

                                    <option value="<?php echo $value1->get_kd_d_kppn(); ?>"><?php echo $value1->get_kd_d_kppn(); ?> | <?php echo $value1->get_nama_user(); ?></option>

        <?php } ?>

                            <?php } ?>

                        </select>
                    <br/>
                    
                    <div id="wf_kanwil" class="alert alert-danger" style="display: none"></div>
                    <label class="isian"> Kanwil: </label>
                    <input class='form-control' type="text" name="f_kanwil" id="f_kanwil" size="50" value="<?php if(isset($this->d_f_kanwil))echo $this->d_f_kanwil;?>">
                    <br/>
                    <div id="wtgl" class='alert alert-danger' style='display:none;'></div>
                    <label class="isian">Tanggal Daftar: </label>
                    <div class="input-daterange input-group" id="datepicker" style="width: 100%">
                        <input class="form-control" type="text" class="tanggal" name="tgl_awal" id="tgl_awal" value="<?php if (isset($this->d_tgl_awal)) {
                            echo $this->d_tgl_awal;
                        } ?>">
                        <span class="input-group-addon">s.d.</span>
                        <input class="form-control" type="text" class="tanggal" name="tgl_akhir" id="tgl_akhir" value="<?php if (isset($this->d_tgl_akhir)) {
                            echo $this->d_tgl_akhir;
                        } ?>">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" name="filter" class="btn btn-primary" style="width: 100%" onClick="">Kirim</button>
                </div>

            </form>

        </div>

    </div>

</div>
<!--end filter-->

<!-- Skrip -->
<script type="text/javascript" charset="utf-8">

</script>